package com.kfm.pm;

public class Demo03 {

    public static void main(String[] args) {
        // 声明一个方法，获取一个数字，计算该数字范围内的素数和
        int result = sumPrime(10);
        System.out.println(result);
    }

    public static int sumPrime(int number) {
        int sum = 0;
        for (int i = 1; i <= number; i++) {
            int count = 0;
            for (int j = 1; j <= i ; j++) {
                if (i % j == 0) {
                    count ++;
                }
                if (count > 2) {
                    break;
                }
            }
            if (count == 2) {
                sum += i;
            }
        }
        return sum;
    }
}
